﻿using System;
using OpenTK;

namespace Mono.Rift.Core.Graphics
{
	public class LightingParams
	{
		public Vector4 Ambient { get; set; }
		public Vector4[] LightPos { get; set; }
		public Vector4[] LightColor { get; set; }
		public float LightCount { get; set; }
		public int Version { get; set; }

		public LightingParams ()
		{
			LightCount = 0;
			Version = 0;
		}

		public void update(Matrix4 view, Vector4[] sceneLightPos)
		{
			Version++;
			for (var i = 0; i < LightCount; i++) {
				LightPos [i] = Vector4.Transform (sceneLightPos [i], view);
			}
		}

		public void set(ShaderSet s)
		{
			s.setUniform4fv ("Ambient", 1, new [] { Ambient });
			s.setUniform1f ("LightCount", LightCount);
			s.setUniform4fv ("LightPos", (int)LightCount, LightPos);
			s.setUniform4fv ("LightColor", (int)LightCount, LightColor);
		}
	}
}

